<template>
  <div class="app-container">
    <el-form ref="queryForm"  :model="form" label-width="68px" :inline="true" >
        <el-form-item label="关键字" label-width="68px">
          <el-input
            v-model="form.key"
            placeholder="请输入查询关键字"
            clearable
            size="small"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['survey:paper:add']"
          >新增</el-button>
        </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="paperList" border @selection-change="handleSelectionChange">
      <el-table-column label="编号" align="center" prop="sid" width="60px"/>
      <el-table-column label="标题" align="left" show-overflow-tooltip >
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="点击量" align="center" prop="click" width="80px"/>
      <el-table-column label="创建人" align="center" prop="createby" width="80px"/>
      <el-table-column label="创建时间" align="center" prop="createtime" width="120px"/>
      <el-table-column label="来源" align="center" prop="source" width="100px"/>
      <el-table-column label="" align="center" width="250px">
        <template slot-scope="scope">
          <el-button type="primary" @click="lookItem(scope.row)" size="mini">查看</el-button>
          <el-button type="primary" @click="modifyItem(scope.row)" size="mini">编辑</el-button>
          <el-button type="danger" @click="deleteItem(scope.row)" size="mini">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog ref="addActical" title="添加新闻" :visible.sync="dialogFormVisible" width="80%" >

      <el-form :model="addform" style="height:500px;" :label-position="labelPosition" label-width="80px" >

            <el-form-item label="标题" >
              <el-input v-model="addform.title" autocomplete="off"></el-input>
            </el-form-item>
        <el-row>
          <el-col :span="12">

            <el-form-item label="创建者"  >
              <el-input v-model="addform.createby" autocomplete="off"></el-input>
            </el-form-item>
          </el-col><el-col :span="12">
            <el-form-item label="来源" >
              <el-input v-model="addform.source" autocomplete="off"></el-input>
            </el-form-item>
        </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="文章内容" >
              <div style="width:100%;height: 450px;border: 1px solid #aaaaaa;">
                <vue-tinymce v-model="content"
                             :setting="setting"></vue-tinymce>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import Vue from 'vue'
  import tinymce from 'tinymce';
  import VueTinymce from '@packy-tang/vue-tinymce';
  //样式
  import 'tinymce/skins/content/default/content.min.css'
  import 'tinymce/skins/ui/oxide/skin.min.css'
  import 'tinymce/skins/ui/oxide/content.min.css'

  //主题
  import 'tinymce/themes/silver'

  //插件
  import 'tinymce/plugins/link' //链接插件
  import 'tinymce/plugins/image' //图片插件
  import 'tinymce/plugins/media' //媒体插件
  import 'tinymce/plugins/table' //表格插件
  import 'tinymce/plugins/lists' //列表插件
  import 'tinymce/plugins/quickbars' //快速栏插件
  import 'tinymce/plugins/fullscreen' //全屏插件
  import 'tinymce/icons/default/icons'
  import '@/utils/zh_CN.js'
  export default {
    name: 'newsIndex',
    components: {},
    data() {
      return {
        // 遮罩层
        loading: false,
        labelPosition: 'right',
        form: {
          key:""
        },
        addform:{
          title:"",
          createby:"",
          source:"",
        },
        dialogFormVisible:false,
        htmlvalue:"",
        paperList:[
          {
            sid:0,
            title:"测测hi策划会ice嘿嘿刺耳hi陈",
            click:1222,
            createby:"李昭",
            createtime:"2021-12-25",
            source:"央视"
          },
          {
            sid:0,
            title:"测测hi策划会ice嘿嘿刺耳hi陈",
            click:1222,
            createby:"李昭",
            createtime:"2021-12-25",
            source:"央视"
          },
          {
            sid:0,
            title:"测测hi策划会ice嘿嘿刺耳hi陈",
            click:1222,
            createby:"李昭",
            createtime:"2021-12-25",
            source:"央视"
          },
          {
            sid:0,
            title:"测测hi策划会ice嘿嘿刺耳hi陈",
            click:1222,
            createby:"李昭",
            createtime:"2021-12-25",
            source:"央视"
          }
        ],
        content: '<h1 style="text-align: center;">长恨歌</h1><p style="text-align: center;">汉皇重色思倾国，御宇多年求不得。<br />杨家有女初长成，养在深闺人未识。<br />天生丽质难自弃，一朝选在君王侧。<br />回眸一笑百媚生，六宫粉黛无颜色。<br />春寒赐浴华清池，温泉水滑洗凝脂。<br />侍儿扶起娇无力，始是新承恩泽时。<br />云鬓花颜金步摇，芙蓉帐暖度春宵。<br />春宵苦短日高起，从此君王不早朝。<br />承欢侍宴无闲暇，春从春游夜专夜。<br />后宫佳丽三千人，三千宠爱在一身。<br />金屋妆成娇侍夜，玉楼宴罢醉和春。<br />姊妹弟兄皆列土，可怜光彩生门户。<br />遂令天下父母心，不重生男重生女。<br />骊宫高处入青云，仙乐风飘处处闻。<br />缓歌慢舞凝丝竹，尽日君王看不足。<br />渔阳鼙鼓动地来，惊破霓裳羽衣曲。</p><p style="text-align: center;">九重城阙烟尘生，千乘万骑西南行。<br />翠华摇摇行复止，西出都门百余里。<br />六军不发无奈何，宛转蛾眉马前死。<br />花钿委地无人收，翠翘金雀玉搔头。<br />君王掩面救不得，回看血泪相和流。<br />黄埃散漫风萧索，云栈萦纡登剑阁。<br />峨嵋山下少人行，旌旗无光日色薄。<br />蜀江水碧蜀山青，圣主朝朝暮暮情。<br />行宫见月伤心色，夜雨闻铃肠断声。<br />天旋日转回龙驭，到此踌躇不能去。<br />马嵬坡下泥土中，不见玉颜空死处。<br />君臣相顾尽沾衣，东望都门信马归。<br />归来池苑皆依旧，太液芙蓉未央柳。<br />芙蓉如面柳如眉，对此如何不泪垂。<br />春风桃李花开夜，秋雨梧桐叶落时。<br />西宫南苑多秋草，落叶满阶红不扫。<br />梨园弟子白发新，椒房阿监青娥老。<br />夕殿萤飞思悄然，孤灯挑尽未成眠。<br />迟迟钟鼓初长夜，耿耿星河欲曙天。<br />鸳鸯瓦冷霜华重，翡翠衾寒谁与共。<br />悠悠生死别经年，魂魄不曾来入梦。</p><p style="text-align: center;">临邛道士鸿都客，能以精诚致魂魄。<br />为感君王辗转思，遂教方士殷勤觅。<br />排空驭气奔如电，升天入地求之遍。<br />上穷碧落下黄泉，两处茫茫皆不见。<br />忽闻海上有仙山，山在虚无缥缈间。<br />楼阁玲珑五云起，其中绰约多仙子。<br />中有一人字太真，雪肤花貌参差是。<br />金阙西厢叩玉扃，转教小玉报双成。<br />闻道汉家天子使，九华帐里梦魂惊。<br />揽衣推枕起徘徊，珠箔银屏迤逦开。<br />云鬓半偏新睡觉，花冠不整下堂来。</p><p style="text-align: center;">风吹仙袂飘飖举，犹似霓裳羽衣舞。<br />玉容寂寞泪阑干，梨花一枝春带雨。<br />含情凝睇谢君王，一别音容两渺茫。<br />昭阳殿里恩爱绝，蓬莱宫中日月长。<br />回头下望人寰处，不见长安见尘雾。<br />惟将旧物表深情，钿合金钗寄将去。<br />钗留一股合一扇，钗擘黄金合分钿。<br />但令心似金钿坚，天上人间会相见。</p><p style="text-align: center;">临别殷勤重寄词，词中有誓两心知。<br />七月七日长生殿，夜半无人私语时。<br />在天愿作比翼鸟，在地愿为连理枝。<br />天长地久有时尽，此恨绵绵无绝期。</p>',
        setting: {
          menubar: false,
          toolbar: "undo redo | fullscreen | formatselect alignleft aligncenter alignright alignjustify | link unlink | numlist bullist | image media table | fontselect fontsizeselect forecolor backcolor | bold italic underline strikethrough | indent outdent | superscript subscript | removeformat |",
          toolbar_drawer: "sliding",
          quickbars_selection_toolbar: "removeformat | bold italic underline strikethrough | fontsizeselect forecolor backcolor",
          plugins: "link image media table lists fullscreen quickbars",
          language: 'zh_CN', //本地化设置
          height: 450
        }
      }
    },
    methods:{
      handleQuery(){

      },
      resetQuery(){
        this.form={key:""};
      },
      handleSelectionChange(){

      },
      lookItem(row){

      },
      modifyItem(row){

      },
      deleteItem(row){

      },
      handleAdd(){
        //添加新的文章
        var that=this;
        that.dialogFormVisible=true;
        that.$refs.addActical.$el.firstChild.style.height = '90%';
      },

    },
    mounted() {
    },
    created() {

      Vue.prototype.$tinymce = tinymce; // 将全局tinymce对象指向给Vue作用域下
      Vue.use(VueTinymce)              // 安装vue的tinymce组件
    }
  }
</script>

<style scoped>
  .selectCondition{
    padding:10px 30px;
  }
</style>
